home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / UUPC11QS.ARJ / STATER.C < prev    next >
C/C++ Source or Header  |  1991-11-17  |  3KB  |  66 lines

  1. /*--------------------------------------------------------------------*/
  2. /*    s t a t e r . c                                                 */
  3. /*                                                                    */
  4. /*    File time and size routines                                     */
  5. /*                                                                    */
  6. /*    Copyright (c) 1991, Andrew H. Derbyshire                        */
  7. /*--------------------------------------------------------------------*/
  8.  
  9. /*--------------------------------------------------------------------*/
  10. /*                   Standard library include files                   */
  11. /*--------------------------------------------------------------------*/
  12.  
  13. #include <stdio.h>
  14. #include <time.h>
  15. #include <sys/types.h>
  16. #include <fcntl.h>
  17. #include <sys/stat.h>
  18.  
  19. /*--------------------------------------------------------------------*/
  20. /*                    UUPC/extended include files                     */
  21. /*--------------------------------------------------------------------*/
  22.  
  23. #include "lib.h"
  24.  
  25. /*--------------------------------------------------------------------*/
  26. /*                      Define current file name                      */
  27. /*--------------------------------------------------------------------*/
  28.  
  29. currentfile();
  30.  
  31. /*--------------------------------------------------------------------*/
  32. /*    s t a t e r                                                     */
  33. /*                                                                    */
  34. /*    Report date and size of a file                                  */
  35. /*--------------------------------------------------------------------*/
  36.  
  37. time_t stater(const char *file, long *size)
  38. {
  39.    struct stat statbuf;
  40.  
  41. /*--------------------------------------------------------------------*/
  42. /*   If the file doesn't exist, give a nasty message to the caller    */
  43. /*--------------------------------------------------------------------*/
  44.  
  45.    if(stat((char *) file, &statbuf) < 0 )
  46.    {
  47.       printmsg(0,"cannot stat %s",file);
  48.       printerr( file );
  49.       if ( size != NULL )
  50.          *size = 0;
  51.       return -1;              /* Flag file as missing          */
  52.    }
  53.  
  54. /*--------------------------------------------------------------------*/
  55. /*          We have the information; return it to the caller          */
  56. /*--------------------------------------------------------------------*/
  57.  
  58.    if ( size != NULL )
  59.       *size = statbuf.st_size;
  60.  
  61.    printmsg(5,"stater: \"%s\" is %ld bytes; updated %s",
  62.          file, *size, ctime( &statbuf.st_ctime));
  63.    return(statbuf.st_ctime);
  64.  
  65. } /* stater */
  66.